<link href="{{ url_for('static', filename='css/tags.css') }}" rel="stylesheet" type="text/css" />
<script src="{{ url_for('static', filename='js/tags.js') }}"></script>

{% with modal_add_tags=ail_tags %}
	{% include 'modals/add_tags.html' %}
{% endwith %}

{% include 'modals/edit_tag.html' %}


<div class="card my-1">
	<div class="card-header" style="background-color:#d9edf7;font-size: 15px">
        <h4 class="text-secondary">{% if meta['username'] %}{{ meta["username"]["id"] }} {% else %} {{ meta['id'] }}{% endif %} </h4>
        {% if meta['icon'] %}
            <div><img src="{{ url_for('objects_image.image', filename=meta['icon'])}}" class="mb-2" alt="{{ meta['id'] }}" width="250" height="250"></div>
        {% endif %}
        <ul class="list-group mb-2">
            <li class="list-group-item py-0">
                <table class="table">
                    <thead class="">
                    <tr>
                        <th>usernames</th>
                        <th>ID</th>
                        <th>First Seen</th>
                        <th>Last Seen</th>
                        <th>NB Chats</th>
                    </tr>
                    </thead>
                    <tbody style="font-size: 15px;">
                    <tr>
                        <td>
                            {% if 'usernames' in meta %}
                                <ul>
                                    {% for username in meta['usernames'] %}
                                        <li>{{ username['id'] }}</li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                {{ meta['username']['id'] }}
                            {% endif %}
                        </td>
                        <td>{{ meta['id']  }}</td>
                        <td>
                            {% if meta['first_seen'] %}
                                {{ meta['first_seen'][0:4] }}-{{ meta['first_seen'][4:6] }}-{{ meta['first_seen'][6:8] }}
                            {% endif %}
                        </td>
                        <td>
                            {% if meta['last_seen'] %}
                                {{ meta['last_seen'][0:4] }}-{{ meta['last_seen'][4:6] }}-{{ meta['last_seen'][6:8] }}
                            {% endif %}
                        </td>
                        <td>{{ meta['chats'] | length }}</td>
                    </tr>
                    </tbody>
                </table>
                {% if meta['info'] %}
                    <li class="list-group-item py-1">
                        <pre class="my-0">{{ meta['info'] }}</pre>
                        {% if meta['translation_info'] %}
                            <hr>
                            <pre class="my-0 text-secondary">{{ meta['translation_info'] }}</pre>
                        {% endif %}
                    </li>
                {% endif %}
            </li>

			<li class="list-group-item py-0">
				<div class="my-2">
					Tags:
					{% for tag in meta['tags'] %}
                        <button class="btn btn-{{ bootstrap_label[loop.index0 % 5] }}"
                                data-toggle="modal" data-target="#edit_tags_modal"
						        data-tagid="{{ tag }}" data-objtype="{{ meta['type'] }}" data-objsubtype="{{ meta['subtype'] }}" data-objid="{{ meta["id"] }}">
                                {{ tag }}
						</button>
					{%  endfor %}
					<button type="button" class="btn btn-light" data-toggle="modal" data-target="#add_tags_modal">
                        <i class="far fa-plus-square"></i>
                    </button>
				</div>
			</li>
		</ul>

		{% with obj_type=meta['type'], obj_id=meta['id'], obj_subtype=meta['subtype'] %}
			{% include 'modals/investigations_register_obj.html' %}
		{% endwith %}
		<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#investigations_register_obj_modal">
			<i class="fas fa-microscope"></i> Investigations
		</button>

        <span class="mb-2 float-right">
            {% if is_correlation %}
                <a href="{{ url_for('chats_explorer.objects_user_account')}}?subtype={{ meta['subtype'] }}&id={{ meta['id'] }}">
                    <button class="btn btn-info"><i class="fas fa-user-circle"></i> Show Object</button>
                </a>
            {% else %}
                <a href="{{ url_for('correlation.show_correlation')}}?type={{ meta['type'] }}&subtype={{ meta['subtype'] }}&id={{ meta['id'] }}">
                    <button class="btn btn-info"><i class="far fa-eye"></i> Correlations &nbsp;
{#                        <span class="badge badge-warning">{{ meta['nb_correlations'] }}</span>#}
                    </button>
                </a>
                <a href="{{ url_for('correlation.show_relationship')}}?type={{ meta['type'] }}&subtype={{ meta['subtype'] }}&id={{ meta['id'] }}">
                    <button class="btn btn-secondary"><i class="far fa-eye"></i> Relationships &nbsp;
{#                        <span class="badge badge-warning">{{ meta['nb_correlations'] }}</span>#}
                    </button>
                </a>
            {% endif %}
        </span>

	</div>
</div>